/**
 * author: MaHX
 * date: 2019/8/27/1:30
 * description:
 **/
public class ShangZhuanXing {
    public static void main(String args[]) {
        Animal animal = new Tiger();
        animal.cry();
//        animal.cath();  无法使用子类新增的方法

        Tiger tiger = new Tiger();
        tiger.cath();
        String str = new String("我喜欢你");
//        System.out.println("调用subString"+str.substring(1));
        System.out.println(tiger.reverse(str));
    }

    public static class Animal {
        public Animal() {
            System.out.println("我是父类构造函数");
        }

        public void cry() {
            System.out.println("啊啊啊");
        }
    }

    public static class Tiger extends Animal {
        String str = new String("我喜欢篮球");

        public Tiger() {
            System.out.println("我是子类构造函数");
        }

        public void cry() {
            System.out.println("吼吼吼");
        }

        public void cath() {
            System.out.println("用虎爪");
            System.out.println(str.charAt(0) + "   and   " + str.substring(1));
        }

        public String reverse(String originStr) {

            if (originStr == null || originStr.length() <= 1)

                return originStr;

            return reverse(originStr.substring(1)) + originStr.charAt(0);

        }
    }
}
